package org.shj.thread.book2.chapter04;

import java.util.Random;

public class ChangerThread extends Thread{

	private Data data;
	private Random random = new Random();
	
	public ChangerThread(String name, Data data){
		super(name);
		this.data = data;
	}
	
	public void run(){
		try{
			for(int i = 0 ; i < 30; i++){
				data.change("No." + i);
				Thread.sleep(random.nextInt(1000));
				data.save();
			}
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}
